﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AForge.Imaging.Filters;

namespace HomeDms.Imaging
{
    public partial class SharpenToolPanel : ImageToolPanel
    {
        public SharpenToolPanel()
        {
            InitializeComponent();
        }

        private void tbrSigma_Scroll(object sender, EventArgs e)
        {
            nudSigma.Value = tbrSigma.Value / 10m;
            Changed();            
        }

        protected override void Execute()
        {
            Sharpen();
        }

        private void Sharpen()
        {
            SharpenEx sharpen = new SharpenEx((double)nudSigma.Value, tbrSize.Value);
            Bitmap = sharpen.Apply(Bitmap);
            InvalidateImage();
        }

        private void nudSigma_ValueChanged(object sender, EventArgs e)
        {
            tbrSigma.Value = (int)Math.Round(nudSigma.Value * 10);
            Changed();
        }

        private void tbrSize_Scroll(object sender, EventArgs e)
        {
            nudSize.Value = tbrSize.Value;
            Changed();
        }

        private void nudSize_ValueChanged(object sender, EventArgs e)
        {
            tbrSize.Value = (int)nudSize.Value;
            Changed();
        }

    }
}
